package edu.kit.aifb.ldstream.stat.distrib;

import java.io.Serializable;

public class ContinuousUniformDistribution implements IDistribution, Serializable {

	private static final long serialVersionUID = 7776106600526137376L;

	private double min;
	private double max;
	
	public ContinuousUniformDistribution(double min, double max){
		this.min = min;
		this.max = max;
	}

	/**
	 * @return the min
	 */
	public double getMin() {
		return min;
	}

	/**
	 * @return the max
	 */
	public double getMax() {
		return max;
	}

	@Override
	public int getDistributionType() {
		return IDistribution.UNIFORM_DISCRETE;
	}

	public boolean equals(Object o){
		if(o instanceof ContinuousUniformDistribution){
			ContinuousUniformDistribution cud = (ContinuousUniformDistribution) o;
			return (Math.abs(this.min - cud.min) < 0.01d) && (Math.abs(this.max - cud.max) < 0.01d);
		}
		return false;
	} 
	
	public int hashCode(){
		return (int) (this.min * IDistribution.UNIFORM_DISCRETE) + (int) (this.max * IDistribution.UNIFORM_DISCRETE);
	}
	
	public String toString(){
		StringBuilder sb = new StringBuilder(" ContinuousUniformDistribution with");
		sb.append("min: ");
		sb.append(this.min);
		sb.append(" max: ");
		sb.append(this.max);
		return sb.toString();
	}
}
